package com.activenetwork.smlite.testcase.events.createEvents.basics;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.activenetwork.custom.uielement.UIElement;
import com.activenetwork.custom.uielement.decorate.IdentifierFactory;
import com.activenetwork.schema.model.event.EventBasicType;
import com.activenetwork.smlite.page.event.EventDetailView.EventBasicSubview;
import com.activenetwork.smlite.snippet.EventsSnippet;
import com.activenetwork.smlite.testcase.BaseCase;
import com.activenetwork.util.EnvContext;
import com.activenetwork.util.verification.gson.FailurePoint;

public class Basics028 extends BaseCase {
	
	static final Logger logger = LoggerFactory.getLogger(Basics028.class);
	private EventBasicType eventBasic;
	
	@BeforeClass(alwaysRun = true)
	public void dataSetup(){
		eventBasic = new EventBasicType();
		EventBasicType.Location location = new EventBasicType.Location();
		eventBasic.setLocation(location);
		
		location.setLocationName("test location postal code maxlength");
	}
	
	@Test
	public void Verify_PostalCode_maximum_length_is_50(){
		loginBusiness.login();
		
		EventBasicSubview eventBasicSubview = EventsSnippet.gotoAddEventPage();
		eventBasicSubview.setEventLocation(eventBasic);
		UIElement postalCode = IdentifierFactory.createUIElement("EventBasicSubview", "locationPostalCode");
		String maxlen = postalCode.getAttribute("maxlength");
		if(!StringUtils.equals(maxlen, "50")){
			EnvContext.failurePointTL.get().add(
					new FailurePoint(Basics028.class.getName(), 
					"Verify location postal code max length is 50", 
					"Location postal code max length is " + maxlen));
		}
		
		loginBusiness.logout();
	}

}
